var message:string = "Hello World" 
console.log(message)
var num:number = 523
console.log(num)
//面向对象编程实例
class Site {
    name():void {//():void 表示不接收参数，无返回值
        console.log("runoob")
    }
}
var child1 = new Site() //实例
child1.name()
//any类型 声明类型不确定的变量
let a: any = 1
a = 'cyh'
a = true
console.log(a)
let arr: any[] = [1,2,"张三",true]
arr[4] = undefined
console.log(arr,"arr")
//使用 | 来支持多种类型
var b: null | number | undefined  
b = null
console.log(b)
//number string boolean
var x1: number = 2
var x2: string = 'string'
var x3: boolean = true
console.log(x1,x2,x3)
//数组
var x4: number[] = [1,2]
var x5: any[] = [1,2,"11",true]
console.log(x4,x5)
//元组
var x6: [string,boolean]
x6 = ["x6",false]
console.log(x6)
//枚举
enum Color {small,middle,big}
var x7: Color = Color.small
console.log(x7)
//void
class F1 {
    f():void{
        console.log("f函数没有返回值")
    }
    f2(num:number):number{
        console.log("f2函数返回值为number类型")
        return num
    }
}
var x8 = new F1().f()
var x9 = new F1().f2(500)
console.log(x9,"x9")
//null
var x10:null = null
//当未声明类型，则根据值得类型来推断类型
var x11 = 2
console.log(x11,"x11")
// x11 = "zhangsan" //编译报错  因为x11已经是number类型了
//变量作用域
var x12:number = 12 //全局变量
class x13Class {
    x13 = 13 ;//实例变量
    static val = 14 ;//静态变量
    sum():string{
        var a:string = '局部变量' //局部变量
        return a
    }
}
var x14 = new x13Class().x13
console.log("全局变量：",x12,)
console.log("静态变量：",x13Class.val)
console.log("实例变量：",x14)
console.log("局部变量：",new x13Class().sum())

